﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RioStudio.Website
{
    public partial class Default : RioPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var lstFeatureImage = tData.Instance.ExecuteReader<RioStudio.Website.Model.Gallery>("Proc_GetAllGalleryIsFeature", true);
                var _image = new RioStudio.Website.Model.Gallery();

                if (lstFeatureImage.Count > 0)
                {
                    var imageCount = lstFeatureImage.Count;

                    Random ran = new Random();

                    _image = lstFeatureImage.ElementAt(ran.Next(0, imageCount));

                    //lblGalleryDate.Text = _image.GalleryDate.ToLongDateString();
                    lblGalleryName.Text = _image.GalleryName;
                    lblGalleryPlace.Text = _image.GalleryPlace;
                    lnkViewAlbum.NavigateUrl = "/Album/" + _image.Slug;
                    lnkImage.NavigateUrl = "/Album/" + _image.Slug;
                    //imgHomePicture.ImageUrl = string.Format("/ImageHandler.axd?image={0}&Height={1}&Width={2}", _image.GalleryAvatar, 420, 680);
                    imgHomePicture.ImageUrl = _image.GalleryAvatar;//420, 680
                }
            }
        }
    }
}